package com.itbaizhan.shopping_order_service.listen;

import com.itbaizhan.shopping_common.pojo.Orders;
import com.itbaizhan.shopping_common.service.OrderService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

@Service
@RocketMQMessageListener(topic = "check_orders_queue", consumerGroup = "check_orders_group")
public class CheckOrderListener implements RocketMQListener<String> {
    @DubboReference
    private OrderService orderService;

    @Override
    public void onMessage(String s) {
        Orders orders = orderService.findById(s);
        if(orders.getStatus() == 1) {
            orders.setStatus(6);
            orderService.update(orders);
        }
    }
}
